package com.oss.mq.common;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;

import java.util.Date;

@Data
public class ResponseBean {
    
    private Integer code;
    private String message;
    private Object data;
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date time;

    private ResponseBean(Integer code, String message, Object data) {
        this.code = code;
        this.message = message;
        this.data = data;
        this.time = new Date();
    }


    public static ResponseBean success(){
        return new ResponseBean(200,"请求成功",null);
    }
    public static ResponseBean success(Object data){
        return new ResponseBean(200,"请求成功",data);
    }
    
    public static ResponseBean error(String message){
        return new ResponseBean(400,message,null);
    }

    public static ResponseBean error(Integer code,String message){
        return new ResponseBean(code,message,null);
    }
    
}
